<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" >
<head>
	<meta charset="UTF-8" />
	<title>这是test.html</title>
	
	<script type="text/javascript" th:src="@{/js/jquery-1.8.3.min.js}"></script>
	
</head>
<body>
	<h1 id="title">这是test.html</h1>
	<h5>后台传的值</h5>
	deptno:<span th:text="' 测试 '+${dept.deptno}"></span>
	dname:<span th:text="${dept.dname}"></span>
	loc:<span th:text="${dept.loc}"></span>
	<div th:object="${dept}">
		deptno:<span th:text="*{deptno}"></span>
		dname:<span th:text="*{dname}"></span>
		loc:<span th:text="*{loc}"></span>
	</div>
	<h5>ajax获取的值</h5>
	<div>
		<ul id="list">
			
		</ul>
	</div>
	
	<script type="text/javascript">
		
		var basePath=getPath();
		window.onload=function(){
			$.ajax({
				url: "http://localhost:8080/demo2/firstDemo/getDeptList",
				type:"post",
				datatype:"json",
				success:function(data){
					
					var html="";
					for(var i=0;i < data.length;i++){
						html+="<li>编号："+data[i].deptno+" 名称："+data[i].dname+" 地址："+data[i].loc+"</li>";	
					}
					
					$("#list").append(html);
				},
				error:function(){
					$("#title").val("ajax请求出错了...");
				}
			});
			
		}
		
		//访问路径
		function getPath(){
			var pathName = window.location.href;   
		    var index = pathName.lastIndexOf("/");   
		    var result = pathName.substr(0,index+1);  
		    return result;
		}
		
	</script>
	
</body>
</html>